<template>
  <div class="layer" ref="layerHeight">
    <!-- 搜索 -->
    <div class="query-layer" ref="headerQuery">
      <queryChild @queryBtn="getQuery"></queryChild>
    </div>
    <!-- 表格 -->
    <div class="content">
      <el-table :data="tableData" style="width: 100%" :height="height">
        <el-table-column prop="date" label="日期" width="180"></el-table-column>
        <el-table-column prop="name" label="名称" width="180"></el-table-column>
        <el-table-column prop="address" label="地址"></el-table-column>
        <el-table-column label="操作">
          <template>
            <el-button type="text">删除</el-button>
            <el-button type="text">修改</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="page-layer" ref="footerPage">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import queryChild from "./components/query.vue";
import publicData from "@A/mixins/publicData";
export default {
  name: "userList",
  mixins: [ publicData ],
  components: {
    queryChild
  },
  data() {
    return {
      height: 0,
      tableData: [
        {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }
      ]
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init(){
      this.$nextTick(()=>{
        this.height = this.$refs.layerHeight.offsetHeight - this.$refs.headerQuery.offsetHeight - this.$refs.footerPage.offsetHeight;
      })
    },
    getQuery(val){
      alert(val);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  },
  watch: {},
};
</script>

<style lang="scss" scoped>
.layer {
  width: 100%;
  min-height: 100%;
  .query-layer{
    width: 100%;
    padding: 10px 0;
  }
  .content{
    width: 100%;
  }
  .page-layer{
    width: 100%;
    padding: 10px 0;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-end;
  }
}
</style>